package com.zkthink.ceres.order.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** 退货理由
 * @author JustArgo 2020/5/14 23:58
 * @return
 */
@Getter
public enum ReturnGoodsReasonEnum {

	BAD_TASTE(1,"口感不好/不喜欢"),
	NOT_MATCHED_CON(2,"商品成分描述不符"),
	QUALITY(3,"质量问题"),
	TIME_NOT_MATCHED(4,"生产日期/保质期描述不符"),
	BAD_PRODUCT(5,"三无产品"),
	OTHER(6,"其他"),
	;

	private int code;

	private String desc;

	ReturnGoodsReasonEnum(int code, String desc){
		this.code = code;
		this.desc = desc;
	}

	public static String findDescByCode(int code){
		ReturnGoodsReasonEnum[] reasonEnums = ReturnGoodsReasonEnum.values();
		for(ReturnGoodsReasonEnum reasonEnum:reasonEnums){
			if(reasonEnum.getCode()==code){
				return reasonEnum.getDesc();
			}
		}
		return "原因未知";
	}

	public static List<Map<String,Object>> generateList(){
		ReturnGoodsReasonEnum[] reasonEnums = ReturnGoodsReasonEnum.values();
		List<Map<String,Object>> reasonList = new ArrayList<>();
		for(ReturnGoodsReasonEnum reasonEnum:reasonEnums){
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("code",reasonEnum.getCode());
			map.put("desc",reasonEnum.getDesc());
			reasonList.add(map);
		}
		return reasonList;
	}

}
